package com.example.demo.Controller;

import com.example.demo.model.UserInfo;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * @param id
     * @return
     */
    @RequestMapping("/getuserbyid")
    public UserInfo getUserById(Integer id) {
        if (id != null && id > 0) { // 前端传递的参数有效
            return userService.getUserById(id);
        } else {
            return new UserInfo();
        }
    }

}
